<template>
    <div class="contain">
        <div class="form">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="用户名">
                    <el-input v-model="form.username"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input v-model="form.password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">立即登陆</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
<style scoped>
    .contain{
        width: 100%;
        height: 100%;
    }
    .form{
        width: 400px;
        height: 400px;
        position: relative;
        transform: translateY(-50%);
        top: 50%;
        margin-left: auto;
        margin-right: auto;
    }
</style>

<script>
// import axios from "axios";
export default {
    name: "home",
    props: ["user"],
    components: {},
    data() {
        return {
            form: {
                username: "",
                password: ""
            }
        };
    },
    methods: {
        onSubmit() {
            // this.$emit("changeuser", true);
            // axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
            var data = {
                            username: this.form.username,
                            password: this.form.password
                        }
            axios.post("login/login", data).then((res)=>{
                // this.$showErrorMessage("error");
                // res.catch(this.$showErrorMessage("error"))
                if(res.data.code === 0) {
                    this.$emit("changeuser", true);
                    console.log(res.data.Authorization)
                }
               
            });
            
        }
    }
};
</script>
